#!/usr/bin/env ruby

require File.join(File.dirname(__FILE__),"spamsack")

SpamSack.create

pop = Net::POP3.new(SpamSack.config["pop3"]["server"])
pop.start(SpamSack.config["pop3"]["username"], SpamSack.config["pop3"]["password"])
pop.mails.each do |mail|
  if IncomingMessageHandler.receive(mail.pop)
    mail.delete
  else
    puts "error: #{mail.to_s}"
  end
end
pop.finish
